package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.StudentAssignmentSubmissions;
import com.ruoyi.system.service.IStudentAssignmentSubmissionsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 学生作业提交Controller
 * 
 * @author ruoyi
 * @date 2025-08-15
 */
@RestController
@RequestMapping("/system/assignmentSubmissions")
public class StudentAssignmentSubmissionsController extends BaseController
{
    @Autowired
    private IStudentAssignmentSubmissionsService studentAssignmentSubmissionsService;

    /**
     * 查询学生作业提交列表
     */
    @PreAuthorize("@ss.hasPermi('system:submissions:list')")
    @GetMapping("/list")
    public TableDataInfo list(StudentAssignmentSubmissions studentAssignmentSubmissions)
    {
        startPage();
        List<StudentAssignmentSubmissions> list = studentAssignmentSubmissionsService.selectStudentAssignmentSubmissionsList(studentAssignmentSubmissions);
        return getDataTable(list);
    }

    /**
     * 导出学生作业提交列表
     */
    @PreAuthorize("@ss.hasPermi('system:submissions:export')")
    @Log(title = "学生作业提交", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, StudentAssignmentSubmissions studentAssignmentSubmissions)
    {
        List<StudentAssignmentSubmissions> list = studentAssignmentSubmissionsService.selectStudentAssignmentSubmissionsList(studentAssignmentSubmissions);
        ExcelUtil<StudentAssignmentSubmissions> util = new ExcelUtil<StudentAssignmentSubmissions>(StudentAssignmentSubmissions.class);
        util.exportExcel(response, list, "学生作业提交数据");
    }

    /**
     * 获取学生作业提交详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:submissions:query')")
    @GetMapping(value = "/{submissionId}")
    public AjaxResult getInfo(@PathVariable("submissionId") Long submissionId)
    {
        return success(studentAssignmentSubmissionsService.selectStudentAssignmentSubmissionsBySubmissionId(submissionId));
    }

    /**
     * 新增学生作业提交
     */
    @PreAuthorize("@ss.hasPermi('system:submissions:add')")
    @Log(title = "学生作业提交", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StudentAssignmentSubmissions studentAssignmentSubmissions)
    {
        return toAjax(studentAssignmentSubmissionsService.insertStudentAssignmentSubmissions(studentAssignmentSubmissions));
    }

    /**
     * 修改学生作业提交
     */
    @PreAuthorize("@ss.hasPermi('system:submissions:edit')")
    @Log(title = "学生作业提交", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StudentAssignmentSubmissions studentAssignmentSubmissions)
    {
        return toAjax(studentAssignmentSubmissionsService.updateStudentAssignmentSubmissions(studentAssignmentSubmissions));
    }

    /**
     * 删除学生作业提交
     */
    @PreAuthorize("@ss.hasPermi('system:submissions:remove')")
    @Log(title = "学生作业提交", businessType = BusinessType.DELETE)
	@DeleteMapping("/{submissionIds}")
    public AjaxResult remove(@PathVariable Long[] submissionIds)
    {
        return toAjax(studentAssignmentSubmissionsService.deleteStudentAssignmentSubmissionsBySubmissionIds(submissionIds));
    }
}
